package com.sx.micowell.framework.binding.adapter.switchview;

import android.widget.ToggleButton;

import androidx.databinding.BindingAdapter;

import com.sx.micowell.framework.binding.BindingCommand;


/**
 * @author: YY
 * @time: 2021/6/2
 * @describe 开关控件的事件绑定
 */
public class viewAdapter {

    @BindingAdapter(value = {"onCheckedChangedCommand"}, requireAll = false)
    public static void setCheckedChanged(final ToggleButton toggleButton, final BindingCommand<Boolean> bindingCommand) {
        toggleButton.setOnCheckedChangeListener((compoundButton, b) ->
                bindingCommand.executeConsumer(b));
    }
}
